import { BrowserWindow, ipcMain, Notification } from "electron";

import getDeskCapture from "./deskCapture";

/***
 * 调用方法
 *  proxy.$ipcApi.send("get_capture",msg).then((res) => {
        imgVal.value = res;
    });
 */
const init = (mainWindow: BrowserWindow) => {
  //  获取当前窗口截图  msg是传递过来的参数
  ipcMain.handle("get_capture", async (event, msg) => {
    const res = await getDeskCapture(mainWindow);
    return res;
  });
  // 显示窗口通知
  ipcMain.handle("showNotification", (event, data) => {
    console.log(111);

    const notification = {
      title: "Basic Notification",
      body: "Notification from the Main process",
    };

    console.log(Notification.isSupported());

    const notice = new Notification(notification);
    setTimeout(() => {
      notice.show();
    }, 2000);
  });
};

export default init;
